package source.model.utility;

import source.model.type.*;

/**
 * This class is used to determine if Units can pass through Terrain of a certain
 * type. Uses arrays to mark UnitTypes that are passable for each TerrainType.
 * 
 * @author Sean Larson
 *
 */
public abstract class TerrainUtility {
	
	public static boolean isPassable( TerrainType t, UnitType u ) {
		UnitType[] passableUnits = TerrainUtility.passableUnits( t );
		
		for ( int i=0; i<passableUnits.length; i++ ) {
			if ( passableUnits[i] == u )
				return true;
		}
		
		return false;
	}

	private static UnitType[] passableUnits( TerrainType t ) {
		switch ( t ) {
		case SOLARWIND:
			// we'll make this impassable terrain for now
			return new UnitType[0];
		case VOID:
			// this will be the regular terrain
			return UnitType.values();
		case PLANET:
			// passable by all units for now...
			return UnitType.values();
		case IONSTORM:
			// make this passable only by explorers for now...
			UnitType[] ret = { UnitType.EXPLORER };
			return ret;
		default:
			return new UnitType[0];
		}
	}
}
